import type { User, Code, UserInfo, PatientList, Patient } from '@/types/user'
import { request } from '@/utils/request'

// 手机号密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('/login/password', 'POST', {
    mobile,
    password
  })

// 获取手机号验证码
export const getMobileCode = (mobile: string, type: Code) =>
  request('/code', 'GET', {
    mobile,
    type
  })

// 手机号验证码登录
export const loginByCode = (mobile: string, code: string) =>
  request<User>('/login', 'POST', {
    mobile,
    code
  })
// 获取个人中心数据
export const getUserInfo = () => request<UserInfo>('/patient/myUser')

// 获取家庭档案(患者)列表
export const getPatientList = () => request<PatientList>('/patient/mylist')

// 添加患者信息
export const addPatient = (patient: Patient) =>
  request('/patient/add', 'POST', patient)

// 编辑患者信息
export const editPatient = (patient: Patient) =>
  request('/patient/update', 'PUT', patient)

// 删除患者信息
export const delPatient = (id: string) =>
  request(`/patient/del/${id}`, 'DELETE')

// 获取患者详情
export const getPatientDetail = (id: string) =>
  request<Patient>(`/patient/info/${id}`)
